<?php
include("../../inc/Function_user.php");
include("../../inc/QRCode/phpqrcode.php");
upower();
$info = userinfo();
if($info['level']<1){ echo "<script>alert('权限不足');window.location.href='/user/';</script>";die;}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<link href="/user/css/style.css" rel="stylesheet" type="text/css" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<title>推广码-会员中心</title>
<script>
		// 设计稿 750px，1rem = 100px，换算方法：px值 × 2 ÷ 100 = rem值
		// 例如：设计稿标注16px → 16 × 2 ÷ 100 = 0.32rem
		(function(){
			var docEl = document.documentElement;
			var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
			function recalc() {
				var clientWidth = docEl.clientWidth;
				if (!clientWidth) return;
				docEl.style.fontSize = (clientWidth / 3.75) + 'px';
			}
			if (!document.addEventListener) return;
			window.addEventListener(resizeEvt, recalc, false);
			document.addEventListener('DOMContentLoaded', recalc, false);
			recalc();
		})();
	</script>
</head>
<body class="body" style='background:#06080b;'>
<div class="erweima">
	<header id="header">
	<section class="head-b head-b1">
		<span class="u-left"><a href="javascript:history.go(-1);" class="back"><img src="/skin/img/back.png"/></a></span>
		<h1 id="t0">推广码</h1>
		<div class="u-right" href="#">
			<a href="/" class="hSearch right"><img src="/skin/img/i_home.png"/></a>
		</div>
	</section>
</header>
	<div class="tupian">
<?php
	$file = "\\user\\erweima\\".$info['yqcode']."1.jpg";
	$font=$_SERVER['DOCUMENT_ROOT']."/fonts/simhei.ttf";
	
	/* if(file_exists($file)){
		echo "<img src='/user/erweima/".$info['uname']."1.jpg' />";
	}
	else{ */
	$name = iconv('utf-8','utf-8',"".$info['yqcode']);
	QRcode::png("http://".$_SERVER['HTTP_HOST']."/reg.php?tuijian=".$info['yqcode']."",$name.".png",6,10);
	$erweimabg = '../images/erweimabg.jpg';//  
    $erweima = getcwd()."/".$name.".png";// 

	$thumb = imagecreatetruecolor(540,540);//
	//$thumb = imagecreatetruecolor(280,280);//
	$color=imagecolorallocate($thumb,233,30,0); 
	//3.
	imagecolortransparent($thumb,$color); 
	imagefill($thumb,0,0,$color); 
	
	$img_content = imagecreatefrompng($erweima);//
	imagecopyresampled($thumb,$img_content,0,0,0,0,530,530,370,370);
	$file_name = $name.".png";
	imagepng($thumb,getcwd()."/".$file_name);
	$erweimabg = imagecreatefromjpeg($erweimabg);

	imagecopy($erweimabg, $thumb, 645, 1870, 0, 0, 530,530);
	
	$textColor=imagecolorallocatealpha($erweimabg,0xff,0xff,0xff,30);
	imagettftext($erweimabg,48,0,675,2550,$textColor,$font,'邀请码: '.$info['yqcode']);//

	$name = iconv('utf-8','gb2312',"".$info['yqcode']);
	
	imagejpeg($erweimabg, $name.'.jpg'); 
	
	echo '<img src="'.$name.'.jpg" />';
	//}
?>
</div>
</div>
</body>
</html>
